﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace John
{
    public partial class Company_company : System.Web.UI.Page
    {
        public string imgname;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    jieshao(); //公司介绍
                    gy(); //供应
                    qg(); //求购
                    zs(); //招商
                    upphb();
                }
                catch
                { }
            }
        }


        private void upphb()
        {
            try
            {
                string userName = Request.QueryString["name"].ToString();
                if (string.IsNullOrEmpty(userName))
                {
                    return;
                }
                UserScreenControl.UPphd(userName);

            }
            catch (Exception ex)
            {
                Response.Write(string.Format("<script>alert('{0}！')</script>", ex.ToString()));
            }

            //DBConn mydb = new DBConn();
            //string sql = "update muser set phb=(select phb from muser where hyname='" + Request.QueryString["name"].ToString() + "') +1 where hyname='" + Request.QueryString["name"].ToString() + "'";
            //mydb.Update(sql);
            //mydb.Close();
        }


        /// <summary>
        /// 单位主页
        /// </summary>
        void jieshao()
        {
            try
            {
                string gsjs = string.Empty;
                string imgName = string.Empty;
                if(String.IsNullOrEmpty(Request.QueryString["name"].ToString()))
                {
                    return;
                }
                UserScreenControl.JieShao(Request.QueryString["name"].ToString(),out gsjs, out imgName);
                Label1.Text = gsjs;
                imgname = imgName;
            }
            catch (Exception ex)
            {
                Response.Write(string.Format("<script>alert('{0}！')</script>", ex.ToString()));
            }
        }

        /// <summary>
        /// 产品供应
        /// </summary>
        void gy()
        {
            //DBConn mydb = new DBConn();
            //string sql = "select count(*) as yj from Products where uname='" + Request.QueryString["name"].ToString() + "'";
            //SqlDataReader dr = mydb.getDataReader(sql);
            //if (dr.Read())
            //{
            //    Label2.Text = dr["yj"].ToString();
            //    if (Label2.Text == "")
            //    {
            //        Label2.Text = "0";
            //    }
            //}
            //dr.Close();
            //mydb.Close();


            try
            {
                string yj = string.Empty;
                if (String.IsNullOrEmpty(Request.QueryString["name"].ToString()))
                {
                    return;
                }
                UserScreenControl.GY(Request.QueryString["name"].ToString(), out yj);
                if (string.IsNullOrEmpty(yj))
                {
                    Label2.Text = "0";
                }
                else
                {
                    Label2.Text = yj;
                }
            }
            catch (Exception ex)
            {
                Response.Write(string.Format("<script>alert('{0}！')</script>", ex.ToString()));
            }
        }


        /// <summary>
        /// 产品求购
        /// </summary>
        void qg()
        {
            //DBConn mydb = new DBConn();
            //string sql = "select count(*) as yj from qqproduct where uname='" + Request.QueryString["name"].ToString() + "'";
            //SqlDataReader dr = mydb.getDataReader(sql);
            //if (dr.Read())
            //{
            //    Label3.Text = dr["yj"].ToString();
            //    if (Label3.Text == "")
            //    {
            //        Label3.Text = "0";
            //    }
            //}
            //dr.Close();
            //mydb.Close();
            try
            {
                string yj = string.Empty;
                if (String.IsNullOrEmpty(Request.QueryString["name"].ToString()))
                {
                    return;
                }
                UserScreenControl.QG(Request.QueryString["name"].ToString(), out yj);
                if (string.IsNullOrEmpty(yj))
                {
                    Label3.Text = "0";
                }
                else
                {
                    Label3.Text = yj;
                }
            }
            catch (Exception ex)
            {
                Response.Write(string.Format("<script>alert('{0}！')</script>", ex.ToString()));
            }

        }

        /// <summary>
        /// 招商
        /// </summary>
        void zs()
        {
        //    DBConn mydb = new DBConn();
        //    string sql = "select count(*) as yj from zhaoshang where hyname='" + Request.QueryString["name"].ToString() + "'";
        //    SqlDataReader dr = mydb.getDataReader(sql);
        //    if (dr.Read())
        //    {
        //        Label4.Text = dr["yj"].ToString();
        //        if (Label4.Text == "")
        //        {
        //            Label4.Text = "0";
        //        }
        //    }
        //    dr.Close();
        //    mydb.Close();
            try
            {
                string yj = string.Empty;
                if (String.IsNullOrEmpty(Request.QueryString["name"].ToString()))
                {
                    return;
                }
                UserScreenControl.ZS(Request.QueryString["name"].ToString(), out yj);
                if (string.IsNullOrEmpty(yj))
                {
                    Label4.Text = "0";
                }
                else
                {
                    Label4.Text = yj;
                }
            }
            catch (Exception ex)
            {
                Response.Write(string.Format("<script>alert('{0}！')</script>", ex.ToString()));
            }
        }
    }
}
